﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo02
{
    class Math
    {

        /*max = arr[0];
           // min = arr[0];//，初始化时min=0，如果不假设最小值为索引0，则数组中没有小于0的数字 故最小值为0*/
        public int Find(ref int max, ref int min, ref int avg, int[] arr)
        {
            int sum = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] > max)
                {
                    max = arr[i];
                }
                if (arr[i] < min)
                {
                    min = arr[i];
                }

                sum += arr[i];
                Console.WriteLine(arr[i]);

            }
            avg = sum / arr.Length;
            return sum;
        }
        public int sum(out int max,out int min,out int avg,int[] arr)
        {
            int sum = 0;
            max = arr[0];
            min = arr[0];
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i]>max)
                {
                    max = arr[i];
                }
                if (arr[i]<min)
                {
                    min = arr[i];
                }
                sum += arr[i];

                Console.WriteLine(arr[i]);
            }
            avg = sum / arr.Length;
            return sum;
        }
    }
}
